package com.freak.wanandroid.model.navigation;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.freak.httpmanager.BaseViewModel;
import com.freak.httpmanager.callback.ApiCallback;
import com.freak.httpmanager.callback.SubscriberCallBack;
import com.freak.wanandroid.bean.NavigationBean;

import java.util.List;

public class NavigationViewModel extends BaseViewModel<NavigationRepository> {
    protected MutableLiveData<List<NavigationBean>> mGetNavigation = new MutableLiveData<>();
    protected MutableLiveData<String> mGetNavigationError = new MutableLiveData<>();

    public NavigationViewModel(@NonNull Application application) {
        super(application);
    }

    void getNavigation() {
        mRepository.getNavigation(new SubscriberCallBack<>(new ApiCallback<List<NavigationBean>>() {
            @Override
            public void onSuccess(List<NavigationBean> model) {
                mGetNavigation.postValue(model);
            }

            @Override
            public void onFailure(String msg) {
                mGetNavigationError.postValue(msg);
            }
        }));
    }
}
